//
//  WZOutCountCell.m
//  ETong
//
//  Created by wanzhao on 15/11/24.
//  Copyright (c) 2015年 wanzhao. All rights reserved.
//

#import "WZOutCountCell.h"

@interface WZOutCountCell ()

//文件按钮
@property (nonatomic, weak) UIButton *fileBtn;
//申请外出时间
@property (nonatomic, weak) UILabel *outApplyLabel;
//申请外出公司名
@property (nonatomic, weak) UILabel *companyNameLabel;
//申请外出地址
@property (nonatomic, weak) UILabel *outAddressLabel;

//申请外出类型
@property (nonatomic, weak) UILabel *outTypeLabel;
//实际外出签到地址
@property (nonatomic, weak) UILabel *outActualLabel;


@end

@implementation WZOutCountCell

+ (instancetype)outCountCellWithTableView:(UITableView *)tableView
{
    static NSString *outCountCellId = @"outCountCellId";
    WZOutCountCell *cell = [tableView dequeueReusableCellWithIdentifier:outCountCellId];
    if (cell == nil) {
        cell = [[WZOutCountCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:outCountCellId];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
//        self.selectionStyle = UITableViewCellSelectionStyleGray;
        self.backgroundColor = ClearColor;
        self.contentView.backgroundColor = ClearColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setUpSubViews];
    }
    return self;
}

- (void)setUpSubViews
{
    UIButton *fileBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [fileBtn setBackgroundImage:[UIImage imageNamed:@"outShijianzhou"] forState:UIControlStateNormal];
    fileBtn.userInteractionEnabled = NO;
    [self.contentView addSubview:fileBtn];
    self.fileBtn = fileBtn;
    
    UILabel *outApplyLabel = [[UILabel alloc] init];
    outApplyLabel.textColor = RGBCOLORWITH16COLOR(0x999999);
    outApplyLabel.font = Font12;
    outApplyLabel.numberOfLines = 0;
    [self.contentView addSubview:outApplyLabel];
    self.outApplyLabel = outApplyLabel;
    
    UILabel *outTypeLabel = [[UILabel alloc] init];
    outTypeLabel.textColor = RGBCOLORWITH16COLOR(0x333333);
    outTypeLabel.font = Font12;
    outTypeLabel.numberOfLines = 0;
    [self.contentView addSubview:outTypeLabel];
    self.outTypeLabel = outTypeLabel;

    UILabel *companyNameLabel = [[UILabel alloc] init];
    companyNameLabel.textColor = RGBCOLORWITH16COLOR(0x333333);
    companyNameLabel.font = Font12;
    companyNameLabel.numberOfLines = 0;
    [self.contentView addSubview:companyNameLabel];
    self.companyNameLabel = companyNameLabel;
    
    UILabel *outAddressLabel = [[UILabel alloc] init];
    outAddressLabel.textColor = RGBCOLORWITH16COLOR(0x999999);
    outAddressLabel.font = Font12;
    outAddressLabel.numberOfLines = 0;
    outAddressLabel.backgroundColor = ClearColor;
    [self.contentView addSubview:outAddressLabel];
    self.outAddressLabel = outAddressLabel;
    
    UILabel *outActualLabel = [[UILabel alloc] init];
    outActualLabel.textColor = RGBCOLORWITH16COLOR(0x999999);
    outActualLabel.numberOfLines = 0;
    outActualLabel.backgroundColor = ClearColor;
    outActualLabel.font = Font12;
    [self.contentView addSubview:outActualLabel];
    self.outActualLabel = outActualLabel;

}


- (void)setOutCountFrame:(WZOutCountFrame *)outCountFrame
{
    _outCountFrame = outCountFrame;
    WZOut *wzOut = outCountFrame.wzOut;
    
    self.outTypeLabel.frame = outCountFrame.outTypeFrame;
    if ([wzOut.typeFlag isEqualToString:@"1"]) {
        self.outTypeLabel.text = @"外出签到";
    } else if ([wzOut.typeFlag isEqualToString:@"2"]) {
        self.outTypeLabel.text = @"外出签退";
    }
    
    
    self.fileBtn.frame = outCountFrame.outFileFrame;
    
    self.outApplyLabel.frame = outCountFrame.outApplyTimeFrame;
    self.outApplyLabel.text = wzOut.signTime;
    
    self.companyNameLabel.frame = outCountFrame.outCompanyFrame;
    self.companyNameLabel.text = wzOut.customerName;
    
    self.outAddressLabel.frame = outCountFrame.outApplyAddressFrame;
    self.outAddressLabel.text = [NSString stringWithFormat:@"应签到地址：%@",wzOut.outAddress];

    self.outActualLabel.frame = outCountFrame.outActualAddressFrame;
    self.outActualLabel.text = [NSString stringWithFormat:@"实际签到地址：%@",wzOut.signAddress
                                ];
}

@end
